package com.icart.repositories;


import com.icart.entities.WoCommentEntity;
import com.icart.entities.WoInfoEntity;
import org.springframework.context.annotation.Scope;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Repository
@Scope("prototype")
public interface WoinfoRepository extends BaseRepository<WoInfoEntity,Integer> {
    @Transactional
    @Query(nativeQuery = true,value = "update wo_info set stat=10 where oid=?1")
    @Modifying(clearAutomatically = true)
    Integer update(String oid);

    @Transactional
    @Query(nativeQuery = true,value = "insert into wo_info (oid, chnid, custcarid, custid, wotype, busiid,planfee, realfee, makefeeman,servman, makefeettime, getfeeman, getfeetime, cometime, tcid, stat, makefee) " +
            "select ?1,creatchn as chnid,?2,?3,'sale',-3,saleprice,saleprice,0,0,?4,0,?5,?6,tcid,10,saleprice from mk_discpack where tcid=?7")
    @Modifying(clearAutomatically = true)
    Integer savewo(String oid,Long custcarid,Long custid,String time,String time1,String time2,Long tcid);
//insert into`wo_info (oid,chnid,custcarid,custid,wotype,busiid,planfee,realfee,servman,makefeeman,makefeettime,getfeeman,getfeetime,cometime,tcid,stat,makefee) select ?1,creatchn as chnid,?2,?3,'sale',-3,saleprice,saleprice,0,0,?4,0,?5,?6,tcid,10,saleprice from mk_discpack where tcid=?7
    @Query(nativeQuery = true,value = "select max(oid) curoid from wo_info where oid like ?1")
    String findmaxid(String day);
}
